﻿<!--
Project: ClipFlair (http://ClipFlair.codeplex.com)
Filename: BaseWindow.xaml
Version: 20150203
-->

<float:FloatingWindow x:Class="ClipFlair.Windows.BaseWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:flip="clr-namespace:FlipPanel;assembly=FlipPanel"
    xmlns:float="clr-namespace:SilverFlow.Controls;assembly=SilverFlow.Controls"                      
    xmlns:widgets="clr-namespace:ClipFlair.UI.Widgets;assembly=ClipFlair.UI.Widgets"
    xmlns:bind="clr-namespace:Utils.Bindings;assembly=Utils"
    xmlns:options="clr-namespace:ClipFlair.Windows.Options"                                          
    xmlns:local="clr-namespace:ClipFlair.Windows;assembly=ClipFlair.Windows.Base"
    mc:Ignorable="d"
    d:DesignHeight="400" d:DesignWidth="400"
                      
    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
    HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
    
    Tag="{Binding ID, Mode=TwoWay}"
    Title="{Binding Title, Mode=TwoWay}"
    IconText="{Binding Title, Mode=TwoWay}"
                      
    Position="{Binding Position, Mode=TwoWay}"
    Width="{Binding Width, Mode=TwoWay}"
    Height="{Binding Height, Mode=TwoWay}"
    Scale="{Binding Zoom, Mode=TwoWay}"
    Canvas.ZIndex="{Binding ZIndex, Mode=TwoWay}"
                      
    Opacity="{Binding Opacity, Mode=TwoWay}"
                   
    CornerRadius="{Binding CornerRadius, Mode=TwoWay}"
    BorderThickness="{Binding BorderThickness, Mode=TwoWay}"                      
    
    AllowDrop="True"
                      
    MoveEnabled="{Binding Moveable, Mode=TwoWay}"
    ResizeEnabled="{Binding Resizable, Mode=TwoWay}"        
    ScaleEnabled="{Binding Zoomable, Mode=TwoWay}"
                      
    MoveMaximizedEnabled="True"
    ResizeMaximizedEnabled="True"
    
    ShowChrome="{Binding TitlebarVisible, Mode=TwoWay}"
    ShowCloseButton="True"
    ShowMinimizeButton="True"
    ShowMaximizeRestoreButton="True"                  
    ShowScreenshotButton="False"
    ShowHelpButton="False"
    >
  <!-- ShowHelpButton is set in code to true when IsTopLevel=true -->

  <VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="DragStates">
      <VisualStateGroup.Transitions>
        <VisualTransition GeneratedDuration="0:0:0.3">
          <VisualTransition.GeneratedEasingFunction>
            <CircleEase EasingMode="EaseIn"/>
          </VisualTransition.GeneratedEasingFunction>
        </VisualTransition>
      </VisualStateGroup.Transitions>
      <VisualState x:Name="Normal"/>
      <VisualState x:Name="DragOver">
        <Storyboard>
          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ContentBorder">
            <!-- TODO: change TargetName -->
            <EasingColorKeyFrame KeyTime="0" Value="#FFFFF7D1"/>
          </ColorAnimationUsingKeyFrames>
        </Storyboard>
      </VisualState>
    </VisualStateGroup>
  </VisualStateManager.VisualStateGroups>

  <!-- hiding screenshot button due to Silverlight security issue: not rendering cross-domain content to WriteableBitmap, enable only at components that don't load Internet content -->
  <!-- not using RTL here since it would also reverse UI like scrollpanes etc. -->

  <float:FloatingWindow.BorderBrush>
    <SolidColorBrush Color="{Binding BorderColor}" />
  </float:FloatingWindow.BorderBrush>

  <float:FloatingWindow.TitleForeground>
    <SolidColorBrush Color="{Binding TitleForegroundColor}" />
  </float:FloatingWindow.TitleForeground>

  <float:FloatingWindow.TitleBackground>
    <SolidColorBrush Color="{Binding TitleBackgroundColor}" />
  </float:FloatingWindow.TitleBackground>

  <float:FloatingWindow.Background>
    <SolidColorBrush Color="{Binding BackgroundColor}" />
  </float:FloatingWindow.Background>

  <float:FloatingWindow.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/SilverFlow.Controls;component/Themes/generic.xaml"/>
        <ResourceDictionary Source="/FlipPanel;component/Themes/DropDownTheme.xaml" />
        <ResourceDictionary Source="/ClipFlair.Windows.Base;component/Themes/Generic.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </float:FloatingWindow.Resources>

  <float:FloatingWindow.Style>
    <Style TargetType="float:FloatingWindow" BasedOn="{StaticResource FloatingWindowStyle}">
      <Setter Property="TitleStyle" Value="{StaticResource ClipFlairTitleStyle}" />
      <Setter Property="ScreenshotButtonStyle"  Value="{StaticResource ClipFlairScreenshotButtonStyle}" />
      <Setter Property="HelpButtonStyle"  Value="{StaticResource ClipFlairHelpButtonStyle}" />
      <Setter Property="OptionsButtonStyle" Value="{StaticResource ClipFlairOptionsButtonStyle}" />
      <Setter Property="MinimizeButtonStyle" Value="{StaticResource ClipFlairMinimizeButtonStyle}" />
      <Setter Property="MaximizeButtonStyle" Value="{StaticResource ClipFlairMaximizeButtonStyle}" />
      <Setter Property="RestoreButtonStyle" Value="{StaticResource ClipFlairRestoreButtonStyle}" />
      <Setter Property="CloseButtonStyle" Value="{StaticResource ClipFlairCloseButtonStyle}" />
    </Style>

  </float:FloatingWindow.Style>

  <BusyIndicator
    BusyContent="Loading..."
    IsBusy="{Binding Busy}"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    HorizontalContentAlignment="Stretch"
    VerticalContentAlignment="Stretch" 
    >

    <flip:FlipPanel
      Name="FlipPanel" 
      HorizontalAlignment="Stretch" 
      VerticalAlignment="Stretch" 
      HorizontalContentAlignment="Stretch"
      VerticalContentAlignment="Stretch"
      Style="{StaticResource FlipPanel_DropDownStyle}"
      >

      <!-- descendents should define children of BaseWindow.FrontContent (implied content property for BaseWindow) in the XAML -->

      <flip:FlipPanel.BackContent>
        <!-- descendents should define children of BaseWindow.PropertyItems in the XAML (defining children of FlipPanel.BackContent will make them show below the scroller and accordion) -->

        <ScrollViewer Background="#E3DAC9" 
                      HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                      HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition Height="29" />
              <RowDefinition Height="40"/>
              <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <widgets:OptionsLoadSaveControl HorizontalAlignment="Stretch"
              Grid.Row="0"
              Name="ctrlOptionsLoadSave"
              LoadURLTooltip="Load component from URL"
              LoadTooltip="Load component from file"
              SaveTooltip="Save component to file"
              Background="{StaticResource ClipFlairActivityToolbarBackground}"
              />

            <!--
            <StackPanel Orientation="Horizontal">
              <Label Style="{StaticResource PropertyLabelStyle}" Content="Options Source (URL):" Target="{Binding ElementName=edOptionsURL}" />
              <TextBox Name="edOptionsURL" Text="{Binding OptionsSource, Mode=TwoWay}" HorizontalAlignment="Stretch" />
            </StackPanel>
            -->

            <StackPanel
              Grid.Row="1"
              Name="propTitle"
              Orientation="Vertical"
              >
              <Label Style="{StaticResource PropertyLabelStyle}" Content="Title:" Target="{Binding ElementName=edTitle}" />
              <TextBox
                Name="edTitle"
                Text="{Binding Title, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                bind:ImmediateSourceUpdate.IsEnabled="True"
                bind:ImmediateSourceUpdate.Source="{Binding Title, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                />
              <!-- ImmediateSourceUpdate is used because of http://social.msdn.microsoft.com/Forums/silverlight/en-US/951bde54-1bd1-4fdc-8148-86d5a5183de8/updatesourcetriggerpropertychanged-is-ignored?forum=silverlightgen&prof=required -->
            </StackPanel>

            <Accordion
              Grid.Row="2"
              SelectionMode="ZeroOrOne"
              SelectionSequence="Simultaneous"
              ExpandDirection="Down"
              HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
              >

              <AccordionItem
                Header="Window Options"
                IsSelected="False"
                Background="Transparent"
                HorizontalAlignment="Stretch"
                HorizontalContentAlignment="Stretch"
                >
                <AccordionItem.Content>
                  
                  <options:BaseOptions x:Name="options" DataContext="{Binding}" /> <!-- uses our DataContext (the View) -->

                </AccordionItem.Content>
              </AccordionItem>

              <AccordionItem
                Header="Content Options"
                IsSelected="True"
                Background="Transparent"
                HorizontalAlignment="Stretch"
                HorizontalContentAlignment="Stretch"
                >
                <AccordionItem.Content>

                  <StackPanel
                    Name="PropertiesPanel"
                    Orientation="Vertical"
                    Margin="10,10,10,10"
                    HorizontalAlignment="Stretch"
                    >

                    <StackPanel.Resources>
                      <Style TargetType="StackPanel" BasedOn="{StaticResource PropertyStackPanelStyle}" />
                      <Style TargetType="Label" BasedOn="{StaticResource PropertyLabelStyle}" />
                    </StackPanel.Resources>

                    <!-- descendents should add items (better be a list of StackPanels) under a clipflair:BaseWindow.PropertyItems node in XAML -->

                  </StackPanel>

                </AccordionItem.Content>
              </AccordionItem>

            </Accordion>

          </Grid>
        </ScrollViewer>

      </flip:FlipPanel.BackContent>

    </flip:FlipPanel>
  </BusyIndicator>

</float:FloatingWindow>
